<?php

namespace Analysis\Controller;

class CurdController extends CommController
{
    public function addons($type)
    {
        $db = D($type);
        
        if (!$db->create(I('post.'), 1)) {
            $this->error($db->getError());
        }
        if ($db->add()) {
            $this->success("处理成功");
        } else {
            $this->error("处理失败");
        }
    }

    public function editons($type, $str, $id)
    {
        $db = D($type);
        if (!$db->create(I('post.'), 2)) {
            $this->error($db->getError());
        }
        if ($db->where($str . "=" . $id)->save()) {
            $this->success("处理成功");
        } else {
            $this->error("处理失败");
        }
    }

    public function cancel($type, $str, $id, $sv)
    {
        $db = M($type);

        if ($db->where($str . "=" . $id)->save(array($sv => 3))) {
            $this->success("处理成功");
        } else {
            $this->error("处理失败");
        }
    }
}
